]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
keyboardManager: Adapt to layout API becoming async
authorJonas Ådahl <jadahl@gmail.com>
Thu, 10 Apr 2025 07:23:55 +0000 (09:23 +0200)
committerMarge Bot <marge-bot@gnome.org>
Fri, 9 May 2025 12:14:05 +0000 (12:14 +0000)
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3690>

js/misc/keyboardManager.js
js/ui/environment.js

index 78c487241c9fcebcec484468eb54d6f12c6b66ca..75d0aa32c3d49df9045cfa978081ad3dda5901d8 100644 (file)
@@ -55,7 +55,7 @@ class KeyboardManager {
         this._currentKeymap = null;
     }
 
-    _applyLayoutGroup(group) {
+    async _applyLayoutGroup(group) {
         let options = this._buildOptionsString();
         let [layouts, variants] = this._buildGroupStrings(group);
         let model = this._xkbModel;
@@ -68,11 +68,16 @@ class KeyboardManager {
             return;
 
         this._currentKeymap = {layouts, variants, options, model};
-        global.backend.set_keymap(layouts, variants, options, model);
+        await global.backend.set_keymap_async(layouts, variants, options, model, null);
     }
 
-    _applyLayoutGroupIndex(idx) {
-        global.backend.lock_layout_group(idx);
+    async _applyLayoutGroupIndex(idx) {
+        await global.backend.set_keymap_layout_group_async(idx, null);
+    }
+
+    async _doApply(info) {
+        await this._applyLayoutGroup(info.group);
+        await this._applyLayoutGroupIndex(info.groupIndex);
     }
 
     apply(id) {
@@ -82,10 +87,9 @@ class KeyboardManager {
 
         if (this._current && this._current.group === info.group) {
             if (this._current.groupIndex !== info.groupIndex)
-                this._applyLayoutGroupIndex(info.groupIndex);
+                this._applyLayoutGroupIndex(info.groupIndex).catch(logError);
         } else {
-            this._applyLayoutGroup(info.group);
-            this._applyLayoutGroupIndex(info.groupIndex);
+            this._doApply(info).catch(logError);
         }
 
         this._current = info;
@@ -95,8 +99,7 @@ class KeyboardManager {
         if (!this._current)
             return;
 
-        this._applyLayoutGroup(this._current.group);
-        this._applyLayoutGroupIndex(this._current.groupIndex);
+        this._doApply(this._current).catch(logError);
     }
 
     setUserLayouts(ids) {
index 64ee2b8e273255b188092c81b93e51360710ae73..659c7633846559354270644910795717c370ab1c 100644 (file)
@@ -31,6 +31,8 @@ Gio._promisify(Gio.DBusProxy.prototype, 'call_with_unix_fd_list');
 Gio._promisify(Gio.File.prototype, 'query_info_async');
 Gio._promisify(Polkit.Permission, 'new');
 Gio._promisify(Shell.App.prototype, 'activate_action');
+Gio._promisify(Meta.Backend.prototype, 'set_keymap_async');
+Gio._promisify(Meta.Backend.prototype, 'set_keymap_layout_group_async');
 
 // We can't import shell JS modules yet, because they may have
 // variable initializations, etc, that depend on this file's